import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
 baseUrl: 'http://192.168.0.190:8081', loginState: uni.getStorageSync('loginState') === 'ok' ?
			true : false, userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}') 
},
	mutations: {
		updateUserInfo(state, userinfo) {
			uni.setStorageSync('userinfo', JSON.stringify(userinfo))
			uni.setStorageSync('loginState', 'ok')
			state.userinfo = userinfo
			state.loginState = true
		},
	},
	actions: {
		updateuserinfo(context, userinfo) {
			context.commit('updateUserInfo', userinfo)
		},
	}
})
export default store
